import confirmorderService from '../../services/confirmorder';
import goodsService from '../../services/goods';
import util from '../../utils/util'
import router from '../../utils/router'
import authorize from '../../utils/authorize'

Page({
  /**
   * 
   * 页面的初始数据
   */
  data: {
    address: null,
    user_info: null,
    options: null,
    goods: null,
    isCreateOrder: false,
    lin_money: 0,
    lin_use_money: 0,
    hasLinqian: true,
    checkLinqian: true,
    pic: '', //图片
    cardNum: 0, //可用优惠
    hascard: false, //弹出优惠券
    cardarr: [], //暂存cardlist数组
    cardmoney: 0, //优惠券可减钱数
    checks: 1, // 1邻钱2优惠券
    csurid: null, //优惠券id
    lucknum: null, //记录第几个券
    hasRed: false, //红包弹框
    redMail: { //传给红包组件
      list: []
    },
    bybslt_money: 0, //红包金额
    bybsltid: null, //记录红包id
    sub: false, //获取优惠卷状态
    authname: '', //验证收货人姓名
    authnum: '', //验证身份证号码
    authcheck: false, //进行身份验证
    sucesauth: false, //已经进行了身份验证
    mvpmask: false, //已经填写了虚拟账号
    mvp: false, //虚拟券商品
    cate_id_2: '', //7952为虚拟券
    cate_id_3: '', //虚拟券的具体名称
    mvpqq: '', //充值为qq
    mvpphone: '', //充值为手机号
    platform: '', //海淘商品
    order_type: '', //海淘商品订单类型
    is_overseas: '', //海购商品
    balance: 0, //余额抵现金额
    cbalance: false, //默认选中余额抵现
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    wx.hideShareMenu();
    if (!options || !options.gsid || !options.bslnid) {
      return wx.showToast({
        title: '下单参数不全',
        icon: 'none',
        duration: 5000
      })
    }

    this.setData({
      address: wx.getStorageSync('address') || null,
      user_info: wx.getStorageSync('user_info') || null,
      options
    });


    // 普通商品
    this.getProduct(() => {
      this.createList();
      this.getbalance();
      // this.getLinqian();
      // this.createRed();
    });

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (getApp().globalData.order) {
      this.createList();
    }
  },

  //获取余额抵现金额
  getbalance() {
    let _this = this;
    let params = {}
    confirmorderService.customerbalance(params, res => {
      console.log(res)
      if (res.code == 1) {
        _this.setData({
          balance: res.data.balance
        })
        _this.getPriceall(2);
      }
    })
  },
  //取消余额抵现
  canBlance() {
    this.setData({
      cbalance: !this.data.cbalance
    })
    this.getPriceall(2);
  },
  // 获取商品详情
  getProduct: function (cb) {
    let options = this.data.options;
    let opt = {
      goods_id: options.gsid,
      store_id: options.bslnid
    };
    goodsService.goods(opt, res => {
      if (res && res.code == 1 && res.data) {
        let data = res.data;
        let sku = '';
        let arr_sku = [];
        let orig_price = '';
        let sale_price = '';
        let sale_price_all = '';
        let org_sale_price_all = '';
        let conch_num_all = '';
        let special_price_all = '';
        let conch_num = '';
        let special_price = '';
        let _this = this;

        if (options.sku_str) {
          data.goodsSku.forEach((item) => {
            if (item.str_attr_val_id == options.sku_str) {
              orig_price = item.orig_price;
              sale_price = item.sale_price;
              special_price = item.special_price;
              conch_num = item.conch_num
              if (item.img) {
                _this.setData({
                  pic: 'https:' + item.img
                })
              } else {
                _this.setData({
                  pic: 'https:' + data.goodsPic[0].url
                })
              }
            }
          });
          arr_sku = options.sku_str.split(',');
          if (arr_sku.lenth == 1) {
            // 单sku
            for (let i in data.goodsParam) {
              if (data.goodsParam[i].attr_value_id == arr_sku[0]) {
                sku += `${i}:${data.goodsParam[i][a].attr_value_name} `;
                return false;
              }
            }
          } else {
            // 双sku
            arr_sku.forEach((item) => {
              for (let i in data.goodsParam) {
                for (let a in data.goodsParam[i]) {
                  if (data.goodsParam[i][a].attr_value_id == item) {
                    sku += `${i}:${data.goodsParam[i][a].attr_value_name} `;
                  }
                }
              }
            })
          }
        } else {
          orig_price = data.goodsSku[0].orig_price;
          sale_price = data.goodsSku[0].sale_price;
          special_price = data.goodsSku[0].special_price;
          conch_num = data.goodsSku[0].conch_num
          _this.setData({
            pic: 'https:' + data.goodsPic[0].url
          })
        }
        special_price_all = util.floatAccMul(special_price, options.goods_num || 1).toFixed(2);
        conch_num_all = util.floatAccMul(conch_num, options.goods_num || 1);
        if (this.data.options.is_conch == 0) {
          sale_price_all = util.floatAccMul(sale_price, options.goods_num || 1).toFixed(2);
        } else if (this.data.options.is_conch == 1) {
          sale_price_all = util.floatAccMul(special_price, options.goods_num || 1).toFixed(2);
        }
        this.setData({
          goods: {
            name: data.goods.name,
            num: options.goods_num || 1,
            sku,
            orig_price,
            sale_price,
            org_sale_price_all: sale_price_all,
            sale_price_all,
            special_price,
            special_price_all,
            conch_num,
            conch_num_all,
            datas: res.data.goods,
          },
          cate_id_2: res.data.goods.cate_id_2 ? res.data.goods.cate_id_2 : '',
          cate_id_3: res.data.goods.cate_id_3 ? res.data.goods.cate_id_3 : '',
          platform: res.data.goods.platform,
          order_type: res.data.goods.platform == 'hktanis' ? 6 : '',
          is_overseas: res.data.goods.is_overseas
        });
        cb && cb();
      }

    })


  },
  // 选择收货地址
  chooseAddress: function () {
    let _this = this;

    authorize('address', (b) => {
      if (b) {
        wx.chooseAddress({
          success(res) {
            res.txt = `${res.provinceName} ${res.cityName} ${res.countyName}${res.detailInfo}`
            wx.setStorageSync('address', res);
            _this.setData({
              address: res
            });
            // cityName:"广州市"
            // countyName:"海珠区"
            // detailInfo:"新港中路397号"
            // nationalCode:"510000"
            // postalCode:"510000"
            // provinceName: "广东省"
            // telNumber :"020-81167888"
            // userName: "张三"
          },
          fail(res) { }
        });
      }
    })


  },

  // 创建订单
  formSubmit: function (e) {
    // 查询优惠卷之后才能点击
    if (this.data.sub != true) {
      return false
    }
    if ((this.data.options.supplier_id == '648' || this.data.options.supplier_id == '26' || this.data.platform == 'hktanis' || this.data.is_overseas == 1) && !this.data.sucesauth) {
      this.setData({
        authcheck: true
      })
      //进行查询身份证号码
      this.userCard();
      return false;
    }
    //虚拟券商品
    if (this.data.cate_id_2 == 7952 && !this.data.mvpmask) {
      this.setData({
        mvp: true
      })
      return false;
    }
    let data = this.data;
    let options = data.options;
    let address = data.address;
    let user_info = data.user_info;

    if (this.extAddress()) {

      this.setData({
        isCreateOrder: true
      });

      let opt = {
        gsid: options.gsid,
        bslnid: options.bslnid,
        urid: user_info.id,
        sku_str: options.sku_str || '',
        goods_num: options.goods_num || 1,
        address: address.txt,
        province_name: address.provinceName,
        city_name: address.cityName,
        tel: address.telNumber,
        buyer_name: address.userName,
        area_name: address.countyName,
        openid: user_info.openid,
        form_id: e.detail.formId,
        score: data.checkLinqian ? data.lin_use_money : '',
        csurid: this.data.csurid,
        bybsltid: this.data.bybsltid,
        front_total_money: this.data.goods.sale_price_all,
        goods_img: this.data.pic,
        wechat_scene: getApp().globalData.scene,
        order_source: getApp().globalData.sharerecord,
        conch: options.is_conch == 1 ? this.data.goods.conch_num_all : '',
        id_card: this.data.authnum,
        id_name: this.data.authname,
        buy_message: this.data.mvpqq == '' ? this.data.mvpphone : this.data.mvpqq,
        order_type: this.data.order_type,
        balance: this.data.cbalance ? this.data.balance : 0
      }
      confirmorderService.createOrder(opt, (res) => {
        if (res && res.code == 1) {
          return this.toPay(res.data);
        }

        this.setData({
          isCreateOrder: false
        });
        return wx.showToast({
          title: res.msg,
          icon: 'none',
          duration: 5000
        });

      })
    }
  },
  // 验证地址
  extAddress: function () {
    let address = this.data.address;
    if (!address || !address.provinceName) {
      return wx.showToast({
        title: '请设置收货地址',
        icon: 'none',
        duration: 2000
      });
      return false;
    }

    if (/西藏|新疆|内蒙|香港|澳门|台北/.test(address.provinceName)) {
      return wx.showToast({
        title: `所在地区当前无法配送`,
        icon: 'none',
        duration: 2000
      });
      return false;
    }

    return true;
  },

  // 支付
  toPay: function (data) {
    var _this = this;
    let user_info = this.data.user_info;
    let opt = {
      run_num: data.run_num,
      total_money: data.total_money,
      openid: user_info.openid,
      bsln_name: user_info.user_nickname,
    }

    confirmorderService.payOrder(opt, res => {
      if (res && res.code == 1) {
        let d = res.data;
        util.toPay(d, b => {
          let str = `orid=${data.orid}&run_num=${data.run_num}&store_id=${_this.data.options.bslnid}`;
          if (b) {
            let activity = wx.getStorageSync('activity');
            if (activity && activity.payorder_get_redpacket == 1) {
              str += `&scene=singlePage`;
            }
            //   // 成功
            //   wx.showToast({
            //     title:'支付成功',
            //     duration:2000
            //   });
            router.go('payhot', str, 'redirectTo');
          } else {
            //   // 失败 从新计算邻钱
            router.go('orderDetail', str, 'redirectTo');
          }
          // return setTimeout(() => {

          // }, 2000);
        })
      } else {
        wx.showToast({
          title: res.msg,
          icon: 'none',
          duration: 5000
        });
      }

      this.setData({
        isCreateOrder: false
      });

    });

  },

  dateAmu(date) {
    var c = '';
    if (date) {
      if (date && date.indexOf('-') > -1) {
        date = date.replace(/\-/g, "/");
        var d = (date && new Date(date)) ? new Date(date) : new Date();
        c = d.getTime();
      }
    }
    return c;
  },
  showHascard() { //显示优惠券弹框
    var animation = wx.createAnimation({
      duration: 500,
      timingFunction: "ease",
      delay: 0
    })
    this.animation = animation
    animation.translateY(500).step()
    this.setData({
      animationData: animation.export(),
      hascard: true
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        hascard: true,
      })
    }.bind(this), 350)
    if (this.data.lucknum !== null) {
      var list = this.data.cardlist; //所有清空
      for (var i = 0; i < list.length; i++) {
        if (i == this.data.lucknum) {
          list[i].active = 1
        }
      }
      this.setData({
        cardlist: list
      })
    }

  },
  hidHascard() { //隐藏优惠券弹框动画
    var animation = wx.createAnimation({
      duration: 500,
      timingFunction: "ease",
      delay: 0
    })
    this.animation = animation
    animation.translateY(500).step()
    this.setData({
      animationData: animation.export(),
    })
    setTimeout(function () {
      animation.translateY(0).step()
      this.setData({
        animationData: animation.export(),
        hascard: false
      })
    }.bind(this), 350)
  },
  restCard() {
    this.hidHascard();
    var list = this.data.cardlist;
    for (var i = 0; i < list.length; i++) {
      list[i].active = 0;
    }
    this.setData({
      cardlist: list
    })
  },
  hidSure() { //点击优惠券确认
    this.hidHascard();
    var list = this.data.cardlist;
    for (var i = 0; i < list.length; i++) {
      if (list[i].active == 1) {
        this.setData({
          csurid: list[i].csurid,
          current_time: list[i].current_time,
          period_validity_s: list[i].period_validity_s,
          period_validity_e: list[i].period_validity_e,
          // checks: 2,
          'goods.sale_price_all': util.floatAccSub(this.data.goods.org_sale_price_all, list[i].reduction),
          cardmoney: list[i].reduction,
          lucknum: i
        })
      }
    }
    this.getPriceall(2) //当有红包的时候
  },
  //createlist 获取创建订单的优惠券列表
  createList() {
    let _this = this;
    let params = this.data.options;
    if (params.is_use_coupon == 0) {
      _this.setData({
        sub: true
      })
      return false;
    }
    goodsService.createlist(params, res => {
      _this.setData({
        sub: true
      })
      if (res.code == 1) {
        var list = res.data.can_use.concat(res.data.can_not_use);
        for (var i = 0; i < list.length; i++) {
          var ch = '';
          var price = util.floatAccSub(_this.data.goods.org_sale_price_all, list[i].full)

          list[i].ch = _this.dateAmu(res.data.current_time) - _this.dateAmu(list[i].period_validity_e);
          var start = _this.dateAmu(res.data.current_time) - _this.dateAmu(list[i].period_validity_s)
          if (list[i].ch <= 0 && list[i].is_use == 0 && price >= 0 && start > 0) {
            if (list[i].is_goods == 1 && list[i].goods_id == _this.data.options.gsid) {
              list[i].status = 1
            } else if (list[i].is_goods == 2 && list[i].goods_id == 0) {
              list[i].status = 1
            }

          } else if (list[i].ch > 0 || list[i].is_use == 1 || price < 0 || start <= 0 || list[i].is_goods != 1) {
            list[i].status = 0
          }
          // debugger
          if (list[0].status == 1) { //默认选中优惠券
            this.setData({
              lucknum: 0,
              cardmoney: list[0].reduction,
              // checks: 2,
              csurid: list[0].csurid,
              // checkLinqian: false,
            })
            this.getPriceall(2);
          }
          list[i].scene = 'pay';
          list[i].active = 0;
          list[i].current_time = res.data.current_time;

        }
        _this.setData({
          cardNum: list.length,
          cardlist: list
        })
        if (getApp().globalData.order) { //兑换完优惠券之后
          if (_this.data.lucknum !== null) {
            var list = _this.data.cardlist; //所有清空
            for (var i = 0; i < list.length; i++) {
              if (i == _this.data.lucknum) {
                list[i].active = 1
              }
            }
            _this.setData({
              cardlist: list
            })
          }
          getApp().globalData.order = false;
        }

      } else {
        _this.setData({
          cardlist: []
        })
      }
    })
  },
  bingmy(e) { //优惠券子组件传递来的数据
    var index = e.detail.index;
    var item = e.detail.item;
    var arr = this.data.cardlist;
    for (var i = 0; i < arr.length; i++) {
      arr[i].active = 0;
    }
    for (var i = 0; i < arr.length; i++) {
      if (index == i) {
        arr[i] = item
      }
    }
    this.setData({
      cardlist: arr
    })
  },
  //---------------- 红包----------------
  // createRed() {//红包列表
  //   let params = {}
  //   confirmorderService.redpack(params, res => {
  //     if (res.code == 1) {
  //       var list = res.data.data;
  //       var lists = 'redMail.list';
  //       for (var i = 0; i < list.length; i++) {
  //         if (i == 0) {
  //           list[i].check = true;
  //         } else {
  //           list[i].check = false
  //         }
  //         if (this.distime(list[i].failure_time, res.data.current_time)) {
  //           list[i].showtime = true;
  //         } else {
  //           list[i].showtime = false;
  //         }
  //       }
  //       this.setData({
  //         [lists]: list,
  //         bybslt_money: list[0].bybslt_money,
  //         bybsltid: list[0].bybsltid
  //       })
  //       this.getPriceall(1)//默认为商品总额-红包-邻钱
  //     }
  //   })
  // },
  // hideRed() { //关闭红包弹框
  //   var animation = wx.createAnimation({
  //     duration: 500,
  //     timingFunction: "ease",
  //     delay: 0
  //   })
  //   this.animation = animation
  //   animation.translateY(500).step()
  //   this.setData({
  //     animationRed: animation.export(),
  //   })
  //   setTimeout(function() {
  //     animation.translateY(0).step()
  //     this.setData({
  //       animationRed: animation.export(),
  //       hasRed: false
  //     })
  //   }.bind(this), 350)
  // },
  // showRed() { //显示红包
  //   var animation = wx.createAnimation({
  //     duration: 500,
  //     timingFunction: "ease",
  //     delay: 0
  //   })
  //   this.animation = animation
  //   animation.translateY(500).step()
  //   this.setData({
  //     animationRed: animation.export(),
  //     hasRed: true
  //   })
  //   setTimeout(function() {
  //     animation.translateY(0).step()
  //     this.setData({
  //       animationRed: animation.export(),
  //       hasRed: true,
  //     })
  //   }.bind(this), 350)
  //   let list = this.data.redMail.list;
  //   let bybsltid = this.data.bybsltid;
  //   let lists = 'redMail.list'
  //   if (bybsltid) {
  //     for (var i = 0; i < list.length; i++) {
  //       if (list[i].bybsltid == bybsltid) {
  //         list[i].check = true
  //       }
  //     }
  //     this.setData({
  //       [lists]: list
  //     })
  //   }
  // },
  restRed() { //关闭前清空选项
    this.hideRed();
    let list = this.data.redMail.list;
    let lists = 'redMail.list';
    if (this.data.bybsltid) {
      for (var i = 0; i < list.length; i++) {
        list[i].check = false;
      }
    } else {
      for (var i = 0; i < list.length; i++) {
        list[i].check = false;
        if (i == 0) {
          list[i].check = true;
        }
      }
    }

    this.setData({
      [lists]: list
    })
  },
  // sureRed() {//点击红包确定
  //   let list = this.data.redMail.list;
  //   let _this = this;
  //   for (var i = 0; i < list.length; i++) {
  //     if (list[i].check) {
  //       _this.setData({
  //         bybslt_money: Number(list[i].bybslt_money).toFixed(2),
  //         bybsltid: list[i].bybsltid
  //       })
  //     }
  //   }
  //   this.hideRed();
  //   // debugger
  //   //根据邻钱的checkLinqian 状态来判断减去的是邻钱还是优惠券
  //   // debugger
  //   if (this.data.checkLinqian) {
  //     this.getPriceall(1)
  //   } else if (this.data.checkLinqian == false && this.data.cardmoney) {
  //     this.getPriceall(2)
  //   } else {
  //     this.getPriceall(3)
  //   }
  // },
  // getRedid(e) {//得到红包id
  //   var list = 'redMail.list';
  //   this.setData({
  //     [list]: e.detail.list
  //   })
  // },
  getPriceall(num) { //得到最终金额 1为减去红包+邻钱 2为减去红包+优惠券 3只选择了红包
    var all = this.data.goods.org_sale_price_all;
    var _this = this;
    if (num == 1) {
      var maybe = util.floatAccMul(all, 0.7)
      if (this.data.bybslt_money >= all) { //红包金额大于商品金额 禁止选中邻钱
        this.setData({
          'goods.sale_price_all': 0.01,
          lin_use_money: 0
        })
      } else { //再判断同时使用红包和邻钱的时候 红包金额大于等于商品总额的70% 计算邻钱
        if (this.data.bybslt_money >= maybe) {
          var lin = util.floatAccSub(all, this.data.bybslt_money);
          var money = util.floatAccSub(lin, 0.01);
          var lins = util.floatAccSub(lin, money);
          this.setData({
            lin_use_money: money,
            'goods.sale_price_all': lins
          })
        } else {
          let price = util.floatAccSub(all, this.data.lin_use_money)
          let money = util.floatAccSub(price, this.data.bybslt_money)
          this.setData({
            'goods.sale_price_all': money
          })
        }
      }

    } else if (num == 2) { //选择为余额抵现➕优惠券的组合 应付金额
      let price = util.floatAccSub(all, this.data.cardmoney);
      let money = '';
      let max_blance = util.floatAccSub(price, 0.01);
      if (this.data.balance > max_blance) {
        this.setData({
          balance: max_blance
        })
      }
      money = util.floatAccSub(price, this.data.balance)
      if (this.data.cbalance) { //选中为余额抵现

      } else { //取消选中余额抵现 只减去优惠券
        money = util.floatAccSub(price, 0)
      }
      if (money <= 0) {
        this.setData({
          'goods.sale_price_all': 0.01
        })
      } else {
        this.setData({
          'goods.sale_price_all': Number(money).toFixed(2)
        })
      }
    } else if (num == 3) {
      var money = util.floatAccSub(all, this.data.bybslt_money);
      if (money <= 0) {
        _this.setData({
          'goods.sale_price_all': 0.01
        })
      } else {
        _this.setData({
          'goods.sale_price_all': money
        })
      }
    }


  },
  distime(data, time) { //对比时间是否为今天
    var d = '';
    var data = data.slice(0, 10).split('-').join('');
    var time = time.slice(0, 10).split('-').join('');
    if (data == time) {
      d = true
    } else {
      d = false
    }
    return d;
  },
  //去往兑换券码页
  goExchange() {
    router.go('exchange', `list=${1}`, 'navigateTo')
  },
  //获得验证号码
  getVal(e) {
    if (e.target.dataset.num == 1) {
      this.setData({
        authname: e.detail.value
      })
    } else if (e.target.dataset.num == 2) {
      this.setData({
        authnum: e.detail.value
      })
    }
  },
  //验证收货人身份证信息
  Authentication() {
    let authname = this.data.authname;
    let authnum = this.data.authnum;
    let reg = /^[a-zA-Z\u4E00-\u9FA5\uf900-\ufa2d·\.s]{2,20}$/;
    if (!authname) {
      wx.showToast({
        title: '请填写收货人真实姓名',
        icon: 'none'
      })
      return false;
    } else if (authname.length < 2 || authname.length > 15) {
      wx.showToast({
        title: '请填写收货人真实姓名',
        icon: 'none'
      })
      return false;
    } else if (!reg.test(authname)) {
      wx.showToast({
        title: '请填写收货人真实姓名',
        icon: 'none'
      })
      return false;
    } else if (!authnum) {
      wx.showToast({
        title: '请填写收货人身份证号码',
        icon: 'none'
      })
      return false;
    } else if (!util.getIdcard(authnum)) {
      wx.showToast({
        title: '请填写正确的身份证号码',
        icon: 'none'
      })
      return false;
    } else {
      wx.showToast({
        title: '认证成功！',
        icon: 'none'
      })
      this.setData({
        authcheck: false,
        sucesauth: true,
        platform: '',
        is_overseas: ''
      })
    }
  },
  //隐藏关闭实名认证
  hideAuth() {
    this.setData({
      authcheck: false
    })
  },
  //赋值vip账号
  getVip(e) {
    if (e.currentTarget.dataset.type == 'QQ') {
      this.setData({
        mvpqq: e.detail.value
      })
    } else {
      this.setData({
        mvpphone: e.detail.value
      })
    }
  },
  //进行输入账号验证
  subMvp() {
    let _this = this;
    if (_this.data.mvpqq == '' && _this.data.cate_id_3 == 7958) {
      wx.showToast({
        title: '请输入QQ账号',
        icon: 'none'
      })
      return false;
    } else if (!(/^[1-9][0-9]{4,9}$/gim.test(_this.data.mvpqq)) && _this.data.cate_id_3 == 7958) {
      wx.showToast({
        title: '输入正确QQ账号',
        icon: 'none'
      })
      return false;
    } else if (_this.data.mvpphone == '' && _this.data.cate_id_3 != 7958) {
      wx.showToast({
        title: '请输入手机号码',
        icon: 'none'
      })
      return false;
    } else if (_this.data.cate_id_3 != 7958 && !(/^1[3|4|5|8|7|9][0-9]\d{4,8}$/.test(_this.data.mvpphone))) {
      wx.showToast({
        title: '输入正确的手机号码',
        icon: 'none'
      })
      return false;
    } else {
      let _this = this;
      wx.showToast({
        title: '验证成功',
        icon: 'none',
        success(res) {
          _this.setData({
            mvp: false,
            mvpmask: true
          })
        }
      })
    }
  },
  //隐藏虚拟券
  hideMvp() {
    this.setData({
      mvp: false
    })
  },
  //获取当前用户身份证号码
  userCard() {
    let params = {};
    let _this = this;
    confirmorderService.user_id_card(params, res => {
      if (res.code == 1) {
        _this.setData({
          authname: res.data.id_name,
          authnum: res.data.id_card
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }
})